 <?php
function search($score, $filter)
{   
    $half = floor(count($filter) / 2); // 取出中間数

    // 判断积分在哪个区间
    if ($score <= $filter[$half - 1]['max']) {
        $filter = array_slice($filter, 0 , $half);
    } else {
        $filter = array_slice($filter, $half , count($filter));
    }

    // 继续递归直到只剩一个元素
    if (count($filter) != 1) {
        $filter = search($score, $filter);
    }

    return $filter;
}


$filter = [
    ['level' => 0, 'min' => 0, 'max' => 200],
    ['level' => 1, 'min' => 201, 'max' => 1000],
    ['level' => 2, 'min' => 1001, 'max' => 3000],
    ['level' => 3, 'min' => 30011, 'max' => 8000],
    ['level' => 4, 'min' => 8001, 'max' => 10000],
    ['level' => 5, 'min' => 1001, 'max' => 20000],
    ['level' => 6, 'min' => 20001, 'max' => 30000],
    ['level' => 7, 'min' => 40001, 'max' => 50000],
    ['level' => 8, 'min' => 50001, 'max' => 60000],
    ['level' => 9, 'min' => 60001, 'max' => 99999999],
    
];

$result = search($_SESSION['exp'], $filter);
$dengji= current($result)['level'];
?>
<div id="header">
    <div class="container">
      
        
        <?php 
            if (isset($_SESSION['usersid'])){
        ?>
        <div class="header_right"> <span class="hidden-xs">您好!</span>

            <span class="f">
            <?php echo $_SESSION['nickname'] . "({$_SESSION['usersid']})" ?>
        
           
            </span>
             <a href="member.php" class="ti">我的账户</a> <span class="hidden-sm hidden-xs">宝币: <span id="dou" class="f dou"><?php echo Trans($_SESSION['points'])?></span></span> | <span class="hidden-sm hidden-xs">银行: <span class="f dou"><?php echo Trans($_SESSION['bankpoints'])?></span> | </span><a href="slogin.php?act=logout" >退出</a> </div>
        <?php 
            }else{
        ?>
        <div class="header_right"> <span class="hidden-sm hidden-xs">您好! 欢迎使用保时捷28平台,请先</span> <a href="login.php">登陆</a> | <a href="reg.php">注册</a> </div>
        <?php 
            }
        ?>
    </div>
</div>

<div class="topbg">
            <div class="top">
                <div class="topl">
                    <a href="/"><img src="/img/i_logo.png"><img src="/img/logosm.png"></a>
                </div>
                <div class="topr">
                    <div class="topr_l"></div>
                   
                    <div class="topr_r"></div>
                  
                
                </div>
            </div>       
         </div>
   
         <div class="navi" id="nav">
            <ul>                
                <li><a href="/" >网站首页</a></li>            
                <li><a href="/active.php">活动专区</a></li>
                <li><a href="/member.php">会员中心</a></li>
                <li><a href="/rankings.php">牛人榜</a></li>
                <li><a href="/game.php">游戏乐园</a></li>            
                <li><a href="/gift.php">兑换奖品</a></li>                
                   
                <li><a href="/merchants.php">合作商家</a></li>
                <li><a href="/goods.php">推荐好友</a></li>
            </ul>
        </div>

<script language="javascript">  
    var obj=null;
    var As=document.getElementById('nav').getElementsByTagName('a');
    obj = As[0];
    for(i=1;i<As.length;i++){
        if(window.location.href.indexOf(As[i].href)>=0)
        obj=As[i];
    }
    obj.id='pick';
</script>

<script type="text/javascript">
$(function(){  
    //获取导航距离页面顶部的距离  
    var toTopHeight = $("#nav").offset().top;  
      
    //监听页面滚动  
    $(window).scroll(function() {  
        //判断页面滚动超过导航时执行的代码  
        if( $(document).scrollTop() > toTopHeight ){  
            //检测是否为IE6。jQuery1.9中去掉了msie的方法，所以只好这样写  
            if ('undefined' == typeof(document.body.style.maxHeight)) {  
                //页面滚动的距离  
                var scrollTop = $(document).scrollTop();  
                //IE6下，用absolute定位，并设置Top值为距离页面顶部的距离  
                $("#nav").css({'position':'absolute','top':scrollTop+'px'});  
            }else{  
                //IE6以上浏览器采用fixed定位  
                $("#nav").addClass("nav_fixed");  
            }  
        }else{//判断页面滚动没有超过导航时执行的代码  
            if ('undefined' == typeof(document.body.style.maxHeight)) {  
                //设置Top值为导航距页面顶部的初始值。（IE6为了防止浏览器一下滚动过多，所以不能采用直接去掉定位的方法）  
                $("#nav").css({'position':'absolute','top':toTopHeight+'px'});  
            }else{  
                //IE6以上浏览器移除fixed定位，采用默认流布局  
                $("#nav").removeClass("nav_fixed");  
            }  
        }  
    });  
});  
</script>


    



